<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改电影基本信息')" />
    <th:block th:include="include :: header('文件上传')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-ticketmoviebaseinfo-edit" th:object="${ticketMovieBaseInfo}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否删除，1为是，0为否：</label>
                <div class="col-sm-8">
                    <input name="del" th:field="*{del}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">电影名：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">导演：</label>
                <div class="col-sm-8">
                    <input name="director" th:field="*{director}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主演：</label>
                <div class="col-sm-8">
                    <input name="actor" th:field="*{actor}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">电影上映年份：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="movieYear"></select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">电影上映区域：</label>
                <div class="col-sm-8">
                    <!--                    <input name="movieArea" class="form-control" type="text">-->
                    <select class="form-control" name="movieArea"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">电影语言：</label>
                <div class="col-sm-8">
                    <!--                    <input name="language" class="form-control" type="text">-->
                    <select class="form-control" name="language"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">电影简介：</label>
                <div class="col-sm-8">
                    <textarea name="introduction" class="form-control">[[*{introduction}]]</textarea>
                </div>
            </div>
            <!--            电影图片存路径-->
            <div class="form-group" style="display: none;">
                <!--                <label class="col-sm-3 control-label">电影图片：</label>-->
                <div class="col-sm-8">
                    <input name="image" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">票价：</label>
                <div class="col-sm-8">
                    <input name="price" th:field="*{price}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态(0即将上映，1上映中，2已下架）：</label>
                <div class="col-sm-8">
                    <input name="state" th:field="*{state}" class="form-control" type="text">
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">操作者用户id：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="operateId" th:field="*{operateId}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">操作者用户名：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="operateName" th:field="*{operateName}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->

            <div class="form-group">
                <label class="font-noraml">电影封面</label>
                <img name="imageold" th:field="*{image}" th:src="*{image}" id="oldImage" style="width: 100%;"/>
                <div class="file-loading">
                    <input id="singleFile" name="file" type="file" >
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/ticketmoviebaseinfo";
        $("#form-ticketmoviebaseinfo-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-ticketmoviebaseinfo-edit').serialize());
            }
        }

        //上传单文件附件
        // $(document).ready(function () {
            // 单图上传
            $("#singleFile").fileinput({
                uploadUrl: ctx + 'common/upload',
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                var rsp = data.response;
                log.info("return url：" + rsp.url)
                log.info("reutrn fileName：" + rsp.fileName);

                $("input[name=image]").val(rsp.fileName);
                // // $("input[name=image]").style = "width:0px;";
                // $("input[name=image]").css("width", "0px");
                $("input[name=imageold]").css("width", "0px");

            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('');
                $("input[name=image]").val("");
                // // $("input[name=image]").style = "width:0px;";
                $("input[name=imageold]").css("width", "0px");
                // $("#oldImage").style = "width:0px;";
            })

        // });

        //页面初始化，初始化年份option
        $.get(ctx + 'system/ticketmovieyear/getYreaList', null, function(data){//param为参数---键值对方式
            $.each(data.array, function(i,item){
                $("select[name=movieYear]").append("<option value='"+item+"'>"+item+"</option>");
            });
        });
        //电影区域类型
        $.get(ctx + 'system/ticketmovieareatype/getAreaTypeList', null, function(data){//param为参数---键值对方式
            $.each(data.array, function(i,item){
                $("select[name=movieArea]").append("<option value='"+item+"'>"+item+"</option>");
            });
        });
        //电影类型
        $.get(ctx + 'system/ticketmovietype/getMovieTypeList', null, function(data){//param为参数---键值对方式
            $.each(data.array, function(i,item){
                $("select[name=language]").append("<option value='"+item+"'>"+item+"</option>");
            });
        });


    </script>
</body>
</html>